<!--选择厂商-->
<template>
    <div>
        <Modal
                class="vaccine-info-modal"
                width="1100px"
                v-model="myVisible"
                title="选择疫苗厂商"
        >
            <Table :columns="vendorColumns" :data="vendorList"></Table>
            <div slot="footer"></div>
        </Modal>
    </div>
</template>

<script>
    import {updatevaccine} from '@/api/inoculate/inoculate';

    export default {
        props: {
            visible: Boolean,
            vendorList: Array,
            rid: Number
        },
        data () {
            return {
                myVisible: this.modalVisible,
                myVisible1: false,

                vendorColumns:[
                    {
                        title: '疫苗名称',
                        key: 'name'
                    },
                    {
                        title: '公司',
                        key: 'company'
                    },
                    {
                        title: '包装',
                        key: 'packaging'
                    },
                    {
                        title: '剂型',
                        key: 'dose'
                    },
                    {
                        title: '计价单位',
                        key: 'unit'
                    },
                    {
                        title: '规格',
                        key: 'rules'
                    },
                    {
                        title: '种类',
                        key: 'type',
                        render: (h, params) => {
                            return h('span',params.row.type+'类');
                        }
                    },
                    {
                        title: '操作',
                        key: 'Action',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {

                                    },
                                    on: {
                                        click: () => {
                                            updatevaccine({
                                                rid: this.rid,
                                                vid: params.row.id
                                            }).then((res) => {
                                                if(res.data.error==0){
                                                    this.$emit('selectVaccineInfo',params.row);
                                                    this.myVisible=false;
                                                }
                                            })
                                        }
                                    }
                                }, '选择'),
                            ]);
                        }
                    },
                ],
            }
        },
        watch: {
            myVisible: function (newVal,oldVal) {
                this.$emit('update:visible', newVal);
            },
            visible: function (val) {
                this.myVisible = val;
            }
        },
        mounted(){

        }
    }
</script>

<style scoped>

</style>
